package gui;

import java.awt.BorderLayout;
import java.awt.EventQueue;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.JButton;
import javax.swing.JSplitPane;
import java.awt.GridLayout;
import java.awt.FlowLayout;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;
import javax.swing.JTabbedPane;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JScrollPane;

public class Aulas extends JFrame {

	private JPanel contentPane;
	private JLabel lblBusqueda;
	private JLabel lblNAula;
	private JLabel lblCurso;
	private JTextField textField;
	private JTextField textField_1;
	private JLabel lblCapacidadMin;
	private JLabel lblResultadosBusqueda;
	private JTextField textField_2;
	private JButton btnBuscar;
	private JButton btnExaminar;
	private JButton btnCrear;
	private JButton btnSalir;
	private JTable table;
	private JScrollPane scrollPane;
	private AulaDescripcion auladescripcion = null;
	private Aulas padreAula;
	
	public void nullauladescripcion()
	{
		this.auladescripcion=null;
	}

	/**
	 * Launch the application.
	 
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					Aulas frame = new Aulas(null);
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}
	*/

	/**
	 * Create the frame.
	 */
	public Aulas(Principal padre) {
		setTitle("Aulas");
		addWindowListener(new WindowAdapter() {
			public void windowClosing(WindowEvent e){
				padre.nullaulas();
			}
		});
		padreAula=this;
		setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
		setBounds(180, 180, 288, 530);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);
		
		lblBusqueda = new JLabel("Busqueda");
		lblBusqueda.setBounds(10, 11, 63, 14);
		contentPane.add(lblBusqueda);
		
		lblNAula = new JLabel(" Aula");
		lblNAula.setBounds(20, 39, 83, 14);
		contentPane.add(lblNAula);
		
		lblCurso = new JLabel("Curso");
		lblCurso.setBounds(20, 64, 83, 14);
		contentPane.add(lblCurso);
		
		textField = new JTextField();
		textField.setColumns(10);
		textField.setBounds(113, 61, 86, 20);
		contentPane.add(textField);
		
		textField_1 = new JTextField();
		textField_1.setColumns(10);
		textField_1.setBounds(113, 36, 86, 20);
		contentPane.add(textField_1);
		
		lblCapacidadMin = new JLabel("Capacidad Min");
		lblCapacidadMin.setBounds(20, 89, 83, 14);
		contentPane.add(lblCapacidadMin);
		
		textField_2 = new JTextField();
		textField_2.setColumns(10);
		textField_2.setBounds(113, 86, 86, 20);
		contentPane.add(textField_2);
		
		btnBuscar = new JButton("Buscar");
		btnBuscar.setBounds(174, 117, 89, 23);
		contentPane.add(btnBuscar);
		
		lblResultadosBusqueda = new JLabel("Resultados de busqueda");
		lblResultadosBusqueda.setBounds(10, 160, 142, 14);
		contentPane.add(lblResultadosBusqueda);
		
		btnExaminar = new JButton("Examinar");
		btnExaminar.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				if(auladescripcion ==  null)
					auladescripcion = new AulaDescripcion(padreAula);
				auladescripcion.setVisible(true);
			}
		});
		btnExaminar.setBounds(10, 463, 89, 23);
		contentPane.add(btnExaminar);
		
		btnCrear = new JButton("Crear");
		btnCrear.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
			}
		});
		btnCrear.setBounds(113, 463, 70, 23);
		contentPane.add(btnCrear);
		
		btnSalir = new JButton("Salir");
		btnSalir.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				padre.nullaulas();
				dispose();
			}
		});
		btnSalir.setBounds(193, 463, 70, 23);
		contentPane.add(btnSalir);
		
		scrollPane = new JScrollPane();
		scrollPane.setBounds(10, 185, 251, 267);
		contentPane.add(scrollPane);
		
		table = new JTable();
		scrollPane.setViewportView(table);
		table.setModel(new DefaultTableModel(
			new Object[][] {
				{null, null},
				{null, null},
				{null, null},
				{null, null},
				{null, null},
				{null, null},
				{null, null},
				{null, null},
				{null, null},
				{null, null},
				{null, null},
				{null, null},
				{null, null},
				{null, null},
				{null, null},
				{null, null},
				{null, null},
				{null, null},
				{null, null},
				{null, null},
			},
			new String[] {
				"Numero Aula", "Capacidad Maxima"
			}
		) {
			boolean[] columnEditables = new boolean[] {
				false, false
			};
			public boolean isCellEditable(int row, int column) {
				return columnEditables[column];
			}
		});
		table.getColumnModel().getColumn(0).setResizable(false);
		table.getColumnModel().getColumn(1).setResizable(false);
	}
}